Gas sensor with first and second electrodes and a reagent for binding the target gas

ABSTRACT

A gas sensor for sensing a target gas, the gas sensor comprising first and second electrodes; a support layer between the first and second electrodes; and a reagent on the support layer for binding the target gas, wherein the first and second electrodes are in electrical contact with the support layer and the reagent.

The present disclosure relates to a gas sensor and a method of sensing a gas.

Point-of-use (PoU) gas sensors find use in a broad range of applications where gas concentration readings are required quickly or in a remote location. As such, there is a need for more accurate, reliable and cost effective PoU gas sensors for different gases.

Soil is an example of a natural medium that is highly complex physically, chemically and biologically, but where straightforward and practical guidance is required to sustain human life. The global population boom that began in the 1960s resulted in surging increase in nitrogen fertilization to supply the required crop yields. Overfertilization has damaged soil health and yields are declining, while the population continues to rise. Most farmers across the world have no way to measure their fertilizer requirements, so practical guidance leans toward overfertilization, to maximise yields. Either food consumption must reduce, or farming technology and practices must change, because soil degradation is not sustainable.

Even in developed countries where farmers have access to laboratory sampling, soil nitrogen changes faster than the sampling time, so measurements are not useful to guide fertilization. As such, there is a particularly pressing need for PoU sensors for quickly and accurately determining soil nitrogen levels. This would greatly help farmers, with little or zero access to soil measurements, to measure crucial soil nutrients with enough accuracy to reduce overfertilization or improve crop yields.

Aspects of the disclosure are set out in the independent claims and optional features are set out in the claims dependent thereon.

In a first aspect, a gas sensor for sensing a target gas is provided, the gas sensor comprising: first and second electrodes; a support layer between the first and second electrodes; and a reagent on the support layer for binding the target gas, wherein the first and second electrodes are in electrical contact with the support layer and the reagent. The reagent may be termed a scrubbing reagent.

In use, when the gas sensor is exposed to the target gas, the target gas is bound by the reagent. This changes the impedance of the support layer/reagent between the first and second electrodes. This change in impedance can be measured and used to determine the concentration or presence of the target gas. The support layer may be porous and/or hygroscopic.

Each electrode may be carbon based. For example, each electrode may be made of carbon ink, glassy carbon, graphite, graphene or carbon black. Each electrode may be metallic. For example, each electrode may be made of a noble metal such as silver, gold, platinum or iridium. Alternatively the electrodes may be made of conductive polymer. Each electrode may be deposited onto the support layer, for example, by evaporation, sputtering or printing, such as screen printing. The first and second electrodes may be interdigitated. The gas sensor may further comprise first and second electrical contacts, respectively connected to the first and second electrodes for connecting the first and second electrodes to a voltage source.

The support layer may be made of a cellulosic material, such as paper, such as filter paper. Alternatively, the support layer may be made of a textile, a fabric, a polymer, a mesh or any other suitable material. The support layer may be micro or nanoporous and/or any hygroscopic material. A wax barrier, for controlling or limiting the spread of the reagent, may surround the electrodes.

The support layer with reagent may be termed a scrubber or gas scrubber. As is well known to the skilled person, a scrubber is a device or structure for capturing, reacting, binding, adsorbing or absorbing a gas. The reagent is a chemical, compound or material that binds or captures the target gas, for example by chemical or physical means, for example by reacting with the gas, solvating the gas, adsorbing the gas or absorbing the gas. The reagent may be in an aqueous solution.

The gas sensor may further comprise a voltage source, wherein the voltage source is configured to apply an electrical potential between the first and second electrodes. An electrical potential may also be termed a voltage or potential bias. The voltage source may be an alternating voltage source. The electrical potential may be an alternating potential. The frequency of the alternating potential may be 1 Hz-1 kHz. The amplitude of the electrical potential may be 1-10 V. Other frequencies and voltages may be used.

The gas sensor may further comprise or be connected to an electronic controller. The controller may be configured to control the electrical potential and/or perform one or more of the steps of the methods of sensing a target gas or measuring the concentration of ions in a sample discussed below. For example, the controller may be configured to perform one of more of: modifying the electrical potential, amplifying signals, digitizing signals, measuring the impedance of the support layer/reagent at one or more times, calculating a rate of change of impedance, and determining a concentration of the target gas or of target ions in a sample based on impedance measurements, for example by comparing impedance measurements with calibration data.

The target gas may be an alkaline gas and the reagent acidic. An alkaline gas is a gas that may accept a hydrogen ion and/or donate an electron pair and/or, when dissolved in water, has a pH greater than 7. An acidic reagent may donate a hydrogen ion and/or accept an electron pair and/or has a pH less than 7 in solution. The reagent may be in solution and may have a concentration equal to or greater than 1 μM, 1 mM, 0.1 M or 1 M. The acidic reagent may be an acid, such as a strong acid, such as sulphuric acid, nitric acid or hydrochloric acid. The target gas may be ammonia or an alkyl amine, for example any alkyl amine that is gaseous at 25° C. and 1 atm. Alkyl amines include trimethylamine and dimethylamine. When the target gas is ammonia, a preferred acidic reagent is sulphuric acid.

Alternatively, the target gas may be an acidic gas and the reagent alkaline. An acidic gas is a gas that may donate a hydrogen ion and/or accept an electron pair and/or, when dissolved in water, has a pH less than 7. An alkaline reagent may accept a hydrogen ion and/or donate an electron pair and/or has a pH greater than 7 in solution. The reagent may be in solution with a concentration equal to or greater than 1 μM, 1 mM, 0.1 M or 1 M. The reagent may be an alkali, such as a metal hydroxide, such sodium hydroxide, potassium hydroxide or calcium hydroxide. The target gas may be carbon dioxide, hydrogen fluoride, hydrogen chloride, hydrogen bromide or hydrogen iodide. When the target gas is carbon dioxide, a preferred alkaline reagent is a metal hydroxide such as sodium hydroxide.

The gas sensor may be a device for determining a quantity of target ions in a sample, the gas sensor further comprising a container for receiving the sample, wherein the container is fluidically connected to the gas sensor. The inside of the container and gas sensor may be sealed, for example from an ambient atmosphere, for example using a lid. The seal may be a gas-tight seal. The container may connect to the gas sensor via a push or screw fit, or by any other suitable means.

In use, a reagent, such as an acidic or alkaline solution, which may be termed a sample solvent, sample activating solution or sample activating reagent, is added to a sample in the container. The reagent converts the target ions into a gaseous species (the target gas) which is released into the container (the gaseous species may be dissolved in the solution before diffusing to the surface of the solution and escaping as a gas). The gaseous species/target gas then migrates through the container to the support layer, is bound by the reagent, and changes the impedance of the support layer/reagent between the first and second electrodes. The change in impedance can be measured and used to determine the concentration of ions in the original sample. Advantageously, the gas sensor eliminates matrix effects due to a complex sample.

The target ions in the sample may be ammonium ions, alkylammonium ions, fluoride ions, chloride ions, bromide ions, iodide ions or bicarbonate ions. The concentration of ions in the sample may be at least 0.01 ppm, preferably at least 0.1 ppm and more preferably at least 1 ppm. The ions in the sample may be in equilibrium with non-ionic forms and/or may be hydrated. The ions in the sample are ions that can be converted into gaseous molecules (either free gaseous molecules or solvated gaseous molecules) by the sample activating reagent. The ratio between free gaseous molecules in the container and solvated molecules is determined by the partial pressure of free gaseous molecules in the container, in accordance with Henry's law. The solvated gaseous molecules may also be in equilibrium with a corresponding solvated ionic species, for example if the gaseous molecules can accept or donate hydrogen ions in water. The balance of this equilibrium may be dependent on a pH of the sample/sample activating solution. Advantageously, since the reagent binds the target gas, it draws the target gas out of the sample container. This reduces the partial pressure of the target gas in the sample chamber, which in turns draws more of the target gas out of the sample/sample activating solution, which in turn causes a solvated ionic form of the target gas (if present) to be converted into the non-ionic gaseous form. For example, solvated aqueous ammonium ions exist in equilibrium with solvated ammonia molecules, which in turn are in equilibrium with surrounding gaseous ammonia. The equilibrium between solvated ammonia ions and solvated ammonia is dependent upon the pH of the sample/sample activating solution. A more alkaline pH pushes the equilibrium towards ammonia. Conversely, a more acidic pH pushes the equilibrium towards ammonium.

The sample may be soil, agricultural run-off, river water, sea water, sewage, blood, urine or an extract of any of these. The sample may be any chemical or biological sample. The concentration of target ions in the sample, particularly in the case of ammonium ions, may be at least 0.01 ppm, preferably at least 0.1 ppm and more preferably at least 1 ppm. Advantageously, soil ammonium concentration may be used to estimate soil nitrate levels using machine learning algorithms, as discussed herein.

The container may contain or be fluidically connected to a reagent for converting the target ions in the sample into the target gas. That is, the reagent may be provided in a vessel containing the reagent, or be connected to vessel containing the reagent. The reagent may be a basic or acidic solution. The basic solution may comprise a base, such as a metal hydroxide, such a sodium hydroxide, potassium hydroxide or calcium hydroxide. The concentration of the base may be at least 0.01 M, preferably at least 0.1 M and more preferably at least 1 M. The acidic solution may comprise an acid, such as sulphuric acid, nitric acid or hydrochloric acid. The concentration of the acid may be at least 0.01 M, preferably at least 0.1 M and more preferably at least 1 M. The sample activating reagent may be contained in a syringe or device for injection of the reagent into the container. The reagent may be sealed in the syringe or device, for example with a chemically resistant seal. Alternatively or additionally, the reagent may be contained within a pouch, capsule or blister pack, each of which may be configured to release the reagent into the container.

In a preferred embodiment, the sample is soil extract, the ions are ammonium ions and the container contains a sodium hydroxide solution. Advantageously, such a device for measuring ammonium ions in soil is particularly robust to weather conditions, soil type and technical ability of the user.

In an aspect, a method of determining a concentration of a target gas is provided, the method comprising: exposing a gas sensor described above to a gas sample comprising the target gas, such that the target gas is bound by the reagent; measuring an impedance of the support layer by applying an electrical potential between the first and second electrodes at a first time; measuring an impedance of the support layer by applying an electrical potential between the first and second electrodes at a second time; and determining the concentration of the target gas based on the impedance at the first time and the impedance at the second time.

The concentration of the target gas may be measured in parts-per notation, for example parts per million, as a partial pressure, a percentage weight, a percentage volume, a number of moles per unit volume or a number of moles per unit mass. The method may further comprise measuring a rate of change in impedance. The method may further comprise measuring the impedance at one or more further times between the first time and the second time, for example by continuously monitoring the impedance between the first time and the second time. The change in impedance may be an increase in impedance. The method may further comprise using and or training a predictive machine learning model on short measurement times between the first and second times. Determining the concentration of the target gas based on the impedance at the first time and the impedance at the second time may comprise comparing: i) the rate of change in impedance after a fixed time, or ii) the time when the rate of change falls below a threshold rate of change, with a calibration curve or list of calibration results, for example by interpolating between two calibration results of the list of calibration results. The method may further comprise preparing a calibration curve or list of calibration results, for example by measuring i) an impedance of the support layer at a first time and the impedance at a second time; ii) the rate of change after a fixed period of time; or iii) the time taken for rate of change to drop below a threshold value, for at least two known target gas concentrations. Advantageously, the method could be used to detect, for example, a gas leak.

In an aspect, a method of determining a concentration of target ions in a sample using a gas sensor is provided, wherein the gas sensor is a gas sensor comprising a container as described above, the method comprising: inserting the sample into the container; mixing the sample with a reagent for converting the target ions in the sample into the target gas, thereby releasing the target gas into the container; measuring an impedance of the support layer by applying an electrical potential between the first and second electrodes at a first time; measuring an impedance of the support layer by applying an electrical potential between the first and second electrodes at a second time; and determining the concentration of ions in the sample based on the impedance at the first time and the impedance at the second time.

For the above methods, the reagent may be the same as any sample activating reagent described above. The target ions and target gas may be the same as any target ions and target gas described above. The sample may be the same as any sample described above. The concentration of target ions may be measured in parts-per notation, for example parts per million, as a percentage weight, a percentage volume, a number of moles per unit volume or a number of moles per unit mass.

The method may further comprise sealing the device after mixing the sample with the solution. The method may further comprise measuring a rate of change in impedance. The method may further comprise measuring the impedance at one or more further times between the first time and the second time, for example by continuously monitoring the impedance between the first time and the second time. The method may further comprise using and or training a predictive machine learning model on short measurement times between the first and second times. Determining the concentration of the target ions based on the impedance at the first time and the impedance at the second time may comprise comparing: i) the rate of change in impedance after a fixed time; or ii) the time when the rate of change falls below a threshold rate of change, with a calibration curve or list of calibration results, for example by interpolating between two calibration results of the list of calibration results. The method may further comprise preparing a calibration curve or list of calibration results, for example by measuring i) an impedance of the support layer at a first time and the impedance at a second; ii) the rate of change after a fixed period of time; or iii) the time taken for rate of change to drop below a threshold value, for at least two known target ion concentrations for a given sample. In a preferred embodiment, the sample is soil extract, the ions are ammonium ions and the container contains a sodium hydroxide solution.

Advantageously, using these methods, farmers can instantly determine crucial soil nutrients using only robust PoU measurements. This approach could enable precision farming of a new calibre, reducing fertilizer requirements, soil degradation and eutrophication, while improving crop yields.

Embodiments will now be described by way of example with reference to the drawings of which:

FIG. 1 illustrates a gas sensor for measuring ammonia concentration;

FIG. 2 is a flow diagram for a method of using the gas sensor of FIG. 1 ;

FIG. 3 illustrates a device for determining a quantity of ammonium ions in soil sample extract;

FIG. 4 is a flow diagram for a method of using the gas sensor of FIG. 3 ;

FIG. 5 illustrates an approach to determining nitrogen levels in soil;

FIG. 6 illustrates time series data concerning dynamics of soil nitrogen;

FIG. 7 illustrates machine learning models to estimate soil nitrate levels and forecast them into the future;

FIG. 8 shows plots of the performance of a range of different paper-based electrical gas sensors;

FIG. S1 illustrates calibration curves for ammonium nitrate in water;

FIG. S2 illustrates a schematic showing electronics for measuring ionic impedance;

FIG. S3 illustrates raw data showing decrease in ionic conductivity (measured as a voltage), as sulphuric acid in a paper scrubber is neutralized by ammonia gas;

FIG. S4 illustrates soil-ammonium measurements made in soil fertilized in a variety of weather conditions;

FIG. S5 illustrates correlation of dryness with rainfall and temperature;

FIG. S6 illustrates prediction of the level of nitrate in soil instantaneously, using supervised machine learning, and both ammonium and nitrate into the future;

FIG. S7 illustrates R² scores for sets of environmental conditions to find a general regressor to estimate levels nitrate;

FIG. S8 illustrates the process of FIG. 7.1 (bottom left) with test inputs from an external lab rather than the inventors' lab;

FIG. S9 illustrates prediction of nitrate using a K-nearest-neighbours algorithm; and

FIG. S10 illustrates the R² score for data in FIG. 7.2 , showing soil-NH₄ ⁺ and soil-NO₃ ⁻ predicted by LSTM ML model 1-12 days into the future.

With reference to FIG. 1 , in a first embodiment, a gas sensor 100 for sensing ammonia gas comprises first and second interdigitated carbon electrodes 102/104 (No. C2130925D1 conductive carbon ink, 55/45 wt % with No. S60118D3 diluent from GWENT Group) screen printed onto a chromatography paper support layer 106 (Whatman™, grade 1 chromatography paper, 20 cm×20 cm, 0.18 mm thickness). The electrodes are dried overnight at room temperature to remove excess organic solvents from the electrodes. The design of the electrodes consists of three interdigitated electrodes with 1 mm spacing between each finger. First and second electrode contacts 110/112, also printed carbon ink, respectively connect to the first and second electrodes 102/104 and are used to connect the first and second electrodes to a voltage source when the sensor is in use, to apply an electrical potential between the first and second electrodes.

A reagent is provided on the support layer for binding ammonia. The first and second electrodes 102/104 are in electrical contact with the support layer 106 and the reagent. A hydrophobic wax barrier, for limiting the spread of the reagent, surrounds the electrodes 102/104. Wax designs using a Xerox ColorQube 8580 are printer onto Office Depot transparent acetate sheets, then heat-transferred to the support layer 106 with a Vevor HP230B heat press (at 180° C.).

In the first embodiment, the reagent is 10 μl of 0.025 M sulphuric acid, which is drop cast onto the support layer 106. In other embodiments, other acids and concentrations may also be used, for instance when the sensor is configured to detect alkaline gases other than ammonia, such as alkyl ammonia gases, or concentrations may by adjusted based on the range of target gas concentrations being measured.

In a second embodiment, the gas sensor 100 is for sensing carbon dioxide, and the reagent is 10 μl of 0.025 M sodium hydroxide. Other alkalis and concentrations may also be used, in particular when the sensor is configured to detect acidic gases other than carbon dioxide, such as hydrogen fluoride, hydrogen chloride, hydrogen bromide or hydrogen iodide, and for different target gas concentrations.

In use, the sensor of the first and second embodiments is connected to an electronic controller. The controller is configured to apply an alternating electrical potential (10 Hz, 4 V amplitude peak-to-peak) between the first and second electrodes and measure the impedance of the support layer 106. This can be achieved using conventional means well known to the skilled person, for example as illustrated in FIG. S2 , which is a schematic showing electronics for measuring ionic impedance.^([27]) An alternating voltage is supplied (Vin) across the electrodes, and the current passing through measured as a voltage (Vout) with a transimpedance amplifier (implemented with an Operational Amplifier), amplified with a resistor (Gain). There is an increase in ionic impedance (decrease in ionic conductivity) during neutralization of the reagent as the target gas contacts the reagent (i.e. the sulphuric acid is neutralised by ammonia in the first embodiment or the sodium hydroxide is neutralised by carbon dioxide in the second embodiment). As the neutralization of the reagent proceeds, the impedance increases. Thus, a change in impedance is indicative of the presence of the target gas (the concentration of the gas need not be determined) and the sensor may be used to determine the presence of the target gas. Alternatively, the concentration of the target gas may be determined in accordance with the following method.

FIG. 2 is a flow diagram for a method of determining a concentration of ammonia gas using the gas sensor of the first embodiment. The method comprises exposing 202 the gas sensor 100 of the first embodiment to a gas sample comprising ammonia. The ammonia is bound by the reagent, changing the impedance of the reagent/support layer 106. The impedance of the support layer 106 is measured 204 by applying an electrical potential between the first and second electrodes 102/104 at a first time. The impedance of the support layer 106 is then measured 206 again by applying an electrical potential between the first and second electrodes 102/104 at a second time. The concentration of ammonia is then determined 208 based on the impedance at the first time and the impedance at the second time. This is achieved by calculating the rate of change of impedance from the first and second impedance measurements. If the rate of change is below a threshold rate of change, it is determined that the reagent is neutralised and the time taken for neutralisation is converted into an ammonia concentration using a calibration curve prepared by measuring the neutralisation time for a range of known ammonia concentrations (previously measured using the gas sensor—a new gas sensor must be used each time). Other ways of determining the ammonia concentration from the impedance measurements are possible, such as determining the rate of change of impedance after a fixed period of exposure of the gas sensor to the target gas, and comparing this with a corresponding calibration curve. This method may also be used to measure carbon dioxide concentration using the gas sensor 100 of the second embodiment, mutatis mutandis.

FIG. 8 shows performance for a range of different paper-based electrical gas sensors (PEGS) prepared in accordance with the above-aspects and embodiments. In this instance, the admittance of PEGS is measured when a sinusoidal signal of 4 V and 10 Hz is applied to the sensors. (For A-C) The horizontal axis shows time and the vertical axis shows the relative change in admittance of the sensor in percentage. (For D) The horizontal axis shows the ammonia concentration the PEGS were exposed to and the vertical axis shows the slope/min (of the drop of the admittance value of the sensor in Figure (A-C). (A) shows four PEGS treated differently: one bare-PEGS (blank) and three acidic PEGS (A-PEGS) with different concentrations of sulfuric acid (H₂SO₄) (0.001 M, 0.01 M and 0.1 M), are exposed to 5% CO₂ for 10 minutes. The signal for all sensors increases overtime. The bar plot shows maximal signal changes in a 10 min interval for the differently treated sensors and the error bars indicate the standard deviation for n=3. (B) is analogous to (A): one bare-PEGS (blank) is compared to three basic PEGS (B-PEGS) with different concentrations of sodium hydroxide (NaOH) (0.001 M, 0.01 M and 0.1 M) when exposed to 5% CO₂ for 10 minutes. The acidic gas neutralizes the alkaline pre-treatment and the signal for B-PEGS initially drops. For low concentrations of base (0.001 M and 0.01 M) the PEGS are depleted quickly and the signal starts increasing again. (C) is the same array used in (A) but exposed to 5 ppm of ammonia for 10 min. For high concentrations of acid (0.01 M and 0.1 M) the alkaline gas neutralizes the acidic pre-treatment and the signal drops constantly over time (slope is the black solid line; slopes for different concentrations of ammonia are summarized in (D)). For the lowest concentration (0.001 M) the acid is depleted quickly and the sensor starts behaving like a bare-PEGS. (D) shows an A-PEGS treated with 0.01 M sulfuric acid and shows the best signal in terms of error and especially sensitivity to ammonia (see (C)). A-PEGS were exposed to a wide range of ammonia concentrations (0.05 ppm to 5 ppm) and the slope of the drop calculated (black solid line in (C)). This gives a linear correlation between slope and ammonia concentration with a coefficient of determination of R²=0.977. At lower concentrations (grey inlet) the errors get bigger. The error bars are the standard deviation for n=3-12.

FIG. 3 i illustrates a third embodiment of a gas sensor 100 for determining a quantity of ammonium ions in a soil sample extract. The gas sensor 100 of the first embodiment, further comprises a chemically inert 50 ml VWR centrifuge tube container 114 with a gas-tight screwcap lid 116. The container 114 and lid 116 are chemically inert. First and second wires 118/120 pass through the lid 116 and connect to the first and second electrode contacts 110/112 of the gas sensor 100, respectively. 1 ml of 15 M sodium hydroxide solution 122 is provided in the bottom of the container 114. As illustrated in FIG. 3 i , in use, an aqueous soil sample extract, comprising ammonium ions, is mixed with the solution 122, releasing ammonia gas into the headspace of the container. The ammonia neutralises the sulphuric acid reagent, changing the impedance of the support layer 106, as is the case with the first embodiment. The change in impedance can then be used to determine the ammonium concentration in the soil sample extract, for example using the method below. Instead of soil extract, the sample can be any sample comprising ammonium ions, including agricultural run-off, river water, sea water, sewage, blood, urine, or an extract of any of these.

In a fourth embodiment, the gas sensor 100 is for determining a quantity of bicarbonate ions in a sample. As such, the gas sensor 100 of the second embodiment further comprises a container 114 with a lid 116, and 1 ml of 5 M sulphuric acid solution is provided in the bottom of the container 114. In use, a sample comprising bicarbonate ions is added to the solution, releasing carbon dioxide into the headspace of the container 114. The carbon dioxide reacts with the hydroxide reagent, changing the impedance of the support layer 106, as is the case with the second embodiment. The change in impedance can then be used to determine the bicarbonate concentration in the sample, for example using the method below. In further embodiments, the sample may comprise other ions, such as alkylammonium ions, fluoride ions, chloride ions, bromide ions, iodide ions or bicarbonate ions, paired with a suitable sample activating solution and reagent. The sample can be any sample comprising bicarbonate ions, including agricultural run-off, river water, sea water, sewage, blood, urine, or an extract of any of these.

FIG. 4 is a flow diagram for a method of determining the concentration of ammonium ions in a soil sample extract using a gas sensor 100, wherein the gas sensor 100 is the gas sensor 100 of the third embodiment. First, the sample is inserted 302 into the container 114. The sample is then mixed 304 with a 15 M sodium hydroxide solution 122 for converting the ammonium ions in the sample into ammonia, thereby releasing ammonia into the headspace of the container 114, where the ammonia diffuses up to the support layer 106 and neutralises the sulphuric acid reagent. The impedance of the support layer is then measured 306 by applying an electrical potential between the first and second electrodes at a first time, and measured 308 again in the same way at a second time. The concentration of ions in the sample is then determined 310 based on the impedance at the first time and the impedance at the second time, as discussed below.

This method has a limit of detection of 3±1 ppm ammonium, up to at least 144 ppm. FIG. S1 shows calibration curves for ammonium nitrate in water (no soil), which verify that the soil measurements are from ammonium alone. Sensing of ammonia with the sensor 100 may be susceptible to interferences from other water-soluble alkaline gases; however, because ammonia has the highest water solubility and is the dominant water-soluble alkaline gas species in common soil samples due to the presence of fertilizer (ammonium nitrate), the signal generated by the sensor 100 largely originates from ammonium. In detail, the soil sample extract is created by pressing 100 ml deionized water through 100 g of soil. A 5 ml soil solution is injected into the container 114. In the container 114, the solubilized soil-ammonium is in equilibrium with solubilized ammonia (Equation 1), which is in equilibrium with volatilized ammonia in the headspace of the container under Henry's law (Equation 2).

NH_(4(aq)) ⁺+OH_((aq)) ⁻↔NH_(3(aq))+H₂O  (1)

NH_(3(aq))↔NH_(3(g))  (2)

The pH is increased to 14 when mixed with the concentrated sodium hydroxide solution 122, shifting the equilibrium toward NH_(3(aq)) and ultimately NH_(3(g)). The ammonia in the headspace of the container once again dissolves in the sulphuric acid on the support layer 106, for example as described in Barandun et. al.,^([27]) and then neutralizes the sulphuric acid causing an increase in the ionic impedance (presumably due to the neutralization of highly mobile H⁺ ions) of the support layer 106 in a concentration dependent manner (see FIG. 3 ii). Neutralization of volatilized ammonia (Equation 3) draws out more ammonium from the soil extract to maintain equilibrium, hence the reagent on the support layer 106 acts as a scrubber of soil-ammonium.

2NH₄ ⁺+2OH⁻+2H⁺+SO₄ ²⁻→2NH₄ ⁺+SO₄ ³⁻+2H₂O  (3)

There is a decrease in ionic impedance during neutralization, which is measured electrically.^([27]) An alternating voltage (10 Hz, 4 V amplitude peak-to-peak) is supplied across the electrodes 102/104 via wires 118/120 (discussed in further detail below), and the current passing through measured as a voltage with a transimpedance amplifier, amplified with a gain resistor (see FIG. S2 ). As the neutralization continues, the impedance of the paper increases slowly and the time it takes to complete or slow dramatically used as the analytical signal shown in FIG. 3 iii (the analytical signal is circled in red and the error shown in grey (calculated by standard deviation of n=5 measurements; see FIG. S3 for raw data). This may be determined by determining the time taken for the rate of change in impedance to drop below a threshold level. In this instance, the time used as analytical signal was A) when the gradient was zero or B) when there was a step change in gradient (>80% change in <10 minutes), which ever happened sooner. Before measuring unknown concentrations, the sensor is calibrated in a range of concentrations of ammonium from 4.5-144 ppm, in soil fertilized with ammonium nitrate; the calibration curve (log-log) is shown in FIG. 3 iv. The inventors' measurements of ammonium concentration were compared to external laboratory measurements with a score of R²=0.85 (FIG. S4 ). A calibration curve for ammonium nitrate in water (no soil) was also measured, to verify the soil measurements are indeed from ammonium alone (FIG. S1 ).

The method of FIG. 4 can also be used with the gas sensor of the fourth embodiment to measure bicarbonate ions in a sample, mutatis mutandis.

Overfertilization with nitrogen fertilizers has damaged the environment and health of soil; yields are declining, while the population continues to rise. Soil is a complex, living organism which is constantly evolving, physically, chemically and biologically. Standard laboratory testing of soil to determine the levels of nitrogen (mainly NH₄ ⁺ and NO₃ ⁻) is infrequent, expensive and slow, but levels of nitrogen vary on short timescales. Current testing practices, therefore, are not useful to guide fertilization. The above PoU sensor of the third embodiment measures levels of NH₄ ⁺ in soil with a level of detection down to 3±1 ppm (R²=0.85) using a chemically functionalized near ‘zero-cost’ paper-based electrical gas sensor. Gas-phase sensing provides a robust method of sensing NH₄ ⁺ inexpensively due to the reduced complexity of the gas-phase sample as opposed to complex liquid samples that are typically extracted from samples of soil. It is demonstrated that PoU NH₄ ⁺ measurements, when combined with soil conductivity, pH and easily accessible weather data, allow instantaneous prediction of levels of NO₃ ⁻ in soil with of R²=0.70 using the following machine learning (ML) model. The same model can predict NO₃ with R²=0.87 when using laboratory-grade sensors. This approach eliminates the need of using dedicated, expensive sensing instruments to determine the levels of NO₃ ⁻ in soil which is difficult to measure reliably with inexpensive technologies. It is also shown that a long short-term memory recurrent neural network model can be used to predict levels of NH₄ ⁺ and NO₃ ⁻ up to 12 days into the future from a single measurement at day one, with R² _(NH4+)=0.64 and R² _(NO3−)=0.70, for unseen weather conditions.

With the approach presented, crucial nitrogenous soil nutrients can be determined and predicted with enough accuracy to forecast the impact of climate on fertilization planning, and tune timing for crop requirements, reducing overfertilization while improving crop yields.

There is a global effort to find practices for food production that can sustainably feed the population, which is expected to surpass 11 billion people by 2050.^([1]), The Haber-Bosch process enabled inexpensive nitrogen-based fertilizers to feed the booming population, with >600% increase in their use in the past 50 years.^([2,3]) Increased fertilization has, however, come with a great environmental cost. Approximately 12% of available arable land is now degraded, of which >240 Mha (˜926,000 mi² or four times the area of France or the state of Texas) is chemically degraded—i.e. contaminated with heavy metals and/or acidified, especially from nitrogen fertilizers, which interfere with nutrient mobility and uptake by plants.^([4,5]) Over-fertilization has visibly destroyed ecosystems by the leaching of excess NO₃ ⁻ into surface waters causing eutrophication, which gives rise to dead zones such as in the Gulf of Mexico.^([6]) Over-fertilization also impacts the soil microbiome.^([7,8]) Although this is an actively studied topic, N fertilization appears to shift relative abundance of certain microbial communities in soil, with important implication on C cycling and ecosystems.

Application of fertilizers is poorly understood and largely varied between regions and countries, for example eight times more is applied per hectare in China than Australia.^([9]) Farmers across the globe typically rely on guidelines from their governments, fertilizer suppliers, or family know-how when deciding the economic optimum rate of fertilization to ensure maximum crop yields. Professional agronomists generally advise along guidelines and look at yields from previous years to estimate fertilizer requirements; they may also take soil samples for laboratory testing prior to sowing. Laboratory testing, however, is an expensive and slow process hence not performed regularly. Soil nitrogen (Soil-N) is crucial for high yields, and nitrogen fertilizer is the most frequently applied fertilizer. The optimal application rate is highly variable, however, since soil-N fluctuates widely with the properties of soil and weather over short timescales. Benchmark guidelines are unable to account for these variations. With the lack of data concerning the current and future nitrogen levels in soil, farmers tend towards overfertilization to protect yields, an environmentally and economically inefficient practice.^([10-13])

Measurement of Soil-N is important for optimizing the use of nitrogen fertilizers and enabling spatiotemporal variable rate fertilization. Indirect spectroscopic precision farming technologies such as crop canopy sensors (e.g., near infrared spectroscopic cameras) can be used to approximate the N requirements of plants.^([14-16]) Indirect spectroscopic techniques, however, do not measure the levels of nitrogen in soil, instead they measure green light from the leaves of plants (related to nitrogenous compounds) to indirectly estimate levels of N fertilizer required. Machine learning algorithms are suitable for calibrating spectra (e.g., near-infrared) to soil-N.^([17]) Spectroscopic methods require plant mass (e.g., leaves), so the measurements cannot be performed until after germination and growth. Fertilizer, however, is usually applied just before seeds are sown, hence spectroscopic techniques rarely help in-season, and only compliment national guidelines. Using ion-selective membranes, levels of nitrogen in soil (mainly in the form of NO₃ and NH₄ ⁺) can be directly detected electrochemically.^([18]) Such sensors can be integrated into Internet-of-Things (IoT) type remote sensors that can provide continuous data streams concerning levels of nitrogen in soil. To provide spatiotemporal resolution, however, many units would need to be deployed to fields.^([19]) Statistical models using machine learning are, therefore, well suited for filling in missing soil data^([20]) and forecasting them into the future.^([21]) Given each sensor node is not disposable (and expensive), they would require collection before harvest (i.e. labour intensive) and are susceptible to theft. They also require infrastructure investments to a wireless network with access points etc. With the challenges such as large investment requirements, sector heterogeneity, data ownership and privacy, user acceptance and lack of interoperability, the adoption of IoT systems for soil sensing has been slow.[²²] Ion-selective electrochemical sensors can also be produced in a small PoU formfactor (e.g., Horiba LAQUAtwin, ELIT 8021). These sensors demonstrate high accuracy for NO₃ ⁻ (R²=0.96)^([23]) and NH₄ ⁺ (R²=0.98)[^(24]) however they are delicate, relatively expensive (i.e. Horiba LAQUAtwin NO₃ sells for ˜350 USD; each electrode ˜150 USD), require sample preparation and calibration.^([25,26])In this work a new and quick approach is demonstrated for determining crucial, but difficult to measure N-levels in soil. A new type of gas-phase NH₄ ⁺ sensor (of the third embodiment above), simulated climate data (i.e. rainfall and temperature) and off-the-shelf soil pH and conductivity sensors are combined with a statistical machine learning model to instantaneously and accurately determine levels of NO₃ ⁻ in soil. It is demonstrated that the N-levels in soil can also be predicted into the future using a long short-term memory recurrent neural network over a 12-day period. With this new approach (FIG. 5 ), fertilization can be provided more precisely to improve yields, while preventing over fertilization, thus environmental degradation.

With reference to FIG. 5 , nitrogen fertilizer is the backbone of modern agriculture, and is typically applied as urea or ammonium nitrate, fuelling the soil-nitrogen cycle. This outputs solvated NH₄ ⁺ and NO₃ ⁻, which are strongly taken up by plant roots. PoU electrical measurements (including a new soil-NH₄ ⁺ sensor disclosed above) are combined with a machine learning model to quantify difficult-to-measure soil nutrients (such as NO₃) and forecast them into the future. This provides real-time dynamic soil nitrogen information to guide fertilization—reduce over-fertilization, understand the effect of weather, and ensure enough plant-available nitrogen to maximise crop yield—without laboratory measurements. At scale, this model could use a bare minimum of readily available input data to quantify and predict crucial outputs (e.g. soil macronutrients) in highly complex systems (such as soil).

Time-Dependent Nitrogen Dynamics in Soil

Understanding how nitrogen species evolve after fertilization, in particular the nitrification from NH₄ ⁺ to NO₃ ⁻, is important to growers for tailoring fertilization to climatic conditions and crop types, while reducing losses and environmental damage^([28]). Time series data concerning dynamics of soil nitrogen were collected over short timescales (<20 days) in experiments simulating soil in a field (FIG. 6 ). To reduce complexity, no plants were grown and the nitrogen dynamics only due to microbial activity, run-off and volatilization (escape of NH_(3(g))) were investigated. 5.1 kg of soil (Westland Top Soil) were placed in 15 L plastic pots and stored in the laboratory without covering their tops. In each experiment, the environmental conditions were controlled in two ways: i) adding a controlled amount of water to simulate rainfall, ii) passing an electrical current through a resistive heating wire (nichrome wire), wrapped around the containers, to control temperature uniformly. The soil type (sandy loam, sieved) and amount of fertilizer added were kept fixed for all experiments (fertilizer NH₄NO₃ was added in the beginning of each experiment to produce a concertation of 120 ppm, approximately equal to 241 kg/ha of NH₄NO₃ or 85 kg/ha nitrogen—calculation in SI). Experiments were performed for eight sets of environmental conditions spanning arid (1 mm/day rainfall) to tropical (10 mm/day rainfall) with temperatures ranging from 19-21° C. (temperate) to 26-34° C. (warm). Measurements of soil temperature, rainfall, pH, electrical conductivity (EC) and NH₄ ⁺ were made in the inventors' laboratory (Guder Research Group—GRG). Levels of pH, EC, NH₄ ⁺ were also measured in an external laboratory (NRM, Cawood Scientific), in addition to dryness and NO₃ ⁻, for comparison and training of the machine learning model. Although when building the machine learning model the dryness values provided by the commercial laboratory were relied upon, dryness is highly correlated with rainfall and temperature (in the inventors' dataset, temperature and rainfall predict dryness using linear regression with R²=0.86, see FIG. S5 and the equation in the SI) hence can be estimated using these two metrics without needing further analytical measurements.

With reference to FIG. 6 , Time series data of soil nitrogen dynamics were measured over short timescales (<20 days), where each corresponds to soil under different environmental conditions. Rainfall and temperature were controlled by adding a controlled amount of water, and passing current through a resistive heating wire (top of FIG. 6 ). Environmental conditions span arid (1 mm rain/day) to tropical (10 mm rain/day), temperate (19-21° C.) and warm (26-34° C.). Initial fertilization with NH₄NO₃ was fixed at 120 ppm. Measurements of soil temperature, rainfall, pH, EC and NH₄ ⁺ were made in the inventors' laboratory (GRG), and pH, EC, dry %, NH₄ ⁺ and NO₃ ⁻ were measured in an external laboratory (NRM) for comparison and training the machine learn model.

With reference to FIG. S4 , after calibration shown in FIG. 3.4 with data from Figure S3 , 35 soil-NH₄ ⁺ measurements were made in soil fertilized with in for a variety of weather conditions (see FIG. 6 ). Soil-NH₄ ⁺ measurements from the inventors' gas-phase NH₄ ⁺ sensor (GRG) compared to external laboratory measurements with a score of R²=0.85.

-   -   Calculation of Fertilization Rate [kg/ha] from Concentration         [ppm] and Soil Parameters     -   Fertilization Rate [kg/ha]=Hectare Area [m²]×Sample         Depth[m]×Density [kg/m³]×Concentration [ppm]     -   Hectare Area=10,000 m²     -   Sample Depth=Pot height=0.26 m     -   Soil Density=774 kg/m³     -   Concentration of NH₄NO₃=120 ppm     -   10,0000×0.26×774×(120/1,000,000)=241 kg/ha

Dynamics of soil NH₄ ⁺: In all time dependent soil experiments, the level of NH₄ ⁺ dropped rapidly over time, levelling out after about a week, independent of the environmental conditions. Temperature played a considerable role only in the case of 1 mm/day rainfall in which the NH₄ ⁺ levels settled at −50 ppm for warm conditions, in comparison to ˜0 ppm for temperature conditions. In all other scenarios, temperature or rainfall only slightly affected the NH₄ ⁺ dynamics without large differences in the trends. Decreasing levels of NH₄ ⁺ result from multiple processes, such as nitrification (i.e. conversion of NH₄ ⁺→NO₂ ⁻+NO₃ ⁻) or environmental losses (leaching or volatilization), that run in parallel; however, the extent of each process might vary with environmental and soil conditions. Soil dehydration tends to limit nitrification, by restricting substrate supply to microbes and lowering activity of enzymes,^([29]) which may explain retention of NH₄ ⁺ at higher temperatures (and low rainfall). This observation is further supported by the fact that the levels of NO₃ ⁻ were lower for warm conditions than temperate conditions.

Dynamics of soil NO₃ ⁻: Nitrification is a complex, aerobic microbial process affected by temperature, moisture, levels of O₂, pH and of course availability of NH₄ ⁺ among other things (e.g., nitrifier populations).^([28]) It was observed that, while at 1 mm/day rainfall the level of NO₃ increased compared to the initial (day zero) concentration, for 3 mm/day it remained relatively unchanged both for warm and temperate conditions. For 5 mm/day rainfall in warm conditions, the levels of NO₃ only slightly increased toward the end of the experiment. For temperate conditions the concentration of NO₃ nearly halved with a rapid drop after day 10. For heavy rainfalls (10 mm/day), the concentrations of NO₃ ⁻ dropped toward zero in a linear manner over the course of the experiments. From these experiments, it could be concluded that the optimum point for maximum nitrification and retention of NO₃ in soil occurs in temperate and drier conditions, which are consistently more favourable than warm and wetter conditions. The reasons behind these trends may differ, however, depending on the conditions. While the run-off caused by the heavy rainfall (i.e. 10 mm/day) may physically leach NO₃ ⁻ away (the excess water was pouring out from the bottom of the pots), less rainfall (5, 3 mm/day) may hinder penetration of O₂ into the soil (i.e. waterlogged soil) therefore reduce nitrification, especially if the climate is temperate so that not enough water is removed from the soil to allow oxygenation.^([30]) The optimal temperatures for nitrification are typically reported between 24-27° C.,^([31]) in line with the inventors' observations. In the experiments where the dryness of soil did not increase, however, temperature did not have a large effect, evidenced by the first 4 days of the experiment with 3 and 5 mm/day rainfall. Dryness (i.e. rainfall+temperature), therefore appears to be a more important factor in determining the levels of NO₃ ⁻ than temperature alone.

Dynamics of soil EC and pH: EC and pH were measured to investigate their correlation with soil nitrogen under different environmental conditions. Due to technical difficulties, it was not possible to complete the EC and pH measurements for all samples in a single day, hence missed measurements which were to be performed in the inventors' laboratories. Nevertheless, no major trends in pH or EC regardless of rainfall or temperature except for the experiments with 1 and 10 mm/day rainfall were observed. For 1 mm/day rainfall, the EC only slightly increased and pH slightly decreased overtime. Ammonium based fertilizers are known to acidify soil therefore decrease pH.^([32,33]) With an increase in the concentration of mobile NO₃ ⁻ ions in soil, EC is also known to increase.^([33]) When the rainfall was increased to 10 mm/day, however, the run-off leached out ionic species from the soil, in turn reducing EC of soil without affecting pH. The EC and pH measurements performed in the inventors' laboratory and externally did not correlate to the degree expected, although the instruments used in the inventors' laboratory were calibrated weekly with calibration solutions to produce reliable measurements. Upon investigation, it was found that the difference in sample preparation was the likely culprit behind differences in the results. The external laboratory dried the soil samples before taking a fixed weight and mixing with water for measurements, whereas the samples were taken directly from the pots without drying and mixed with water, which caused varied values for EC and pH. In any case, in the context of this work, these differences in sample preparation did not affect the underlying trends in the data generated by the external laboratory and such small errors may happen under real experimental conditions at the point-of-use (hence the entire system should be robust enough to absorb these errors).

Retention, conversion or loss of nutrients added to soil is a complex function of rainfall, temperature, pH, microbe populations, soil type etc. This complexity renders creation of deterministic models to understand the relationship between nitrogenous species and their levels in soil, difficult (if not impossible) after some time, even if initial concentrations are known. The inventors have, therefore, attempted to create a statistical model using (existing) ML approaches to predict levels of hard-to-measure NO₃ ⁻ in soil using information concerning weather (i.e. rainfall and temperature), time since fertilization, pH, EC, and NH₄ ⁺.

Using supervised ML, the inventors attempted to predict the level of NO₃ ⁻ in soil instantaneously, and both NH₄ ⁺ and NO₃ ⁻ into the future (see FIG. S6 for the ML prediction process flow). The measurements performed by the external laboratory (FIG. 6 ) were used as a training set. The performance of the model was then tested either with data from the external lab or data generated by the PoU sensors in the inventors' lab as inputs. Training data matching the same environmental conditions (temperature and rainfall) as the test inputs were removed, so the model was always tested on unseen environmental conditions. Features were ranked in order of importance (by XGBoost, FIG. 7.1 top left), where soil dryness, time since fertilization and NH₄ ⁺ were the most important. Combinations of features, regressors and tuning parameters were compared exhaustively (by grid search) to find the best general regressor to estimate the levels of NO₃ ⁻ instantaneously (see FIG. S7 for R² scores for each set of environmental conditions). It was determined that the K-nearest-neighbours (Knn) algorithm, trained on all 7 features with tuning parameters of k=14, leaf size=1 and p=1, can predict instantaneous levels of NO₃ ⁻ with R²=0.63 using external lab results for training and the inventors' lab PoU sensors for test input (FIG. 7.1 bottom left). Using the same model, but with external lab results as test inputs, removes the impact of inaccuracy from the inventors' lab sensors, resulting in R²=0.68 (FIG. S8 ). It was also determined that XGBoost regressor produced the best predictions for dryer soils and Knn for wetter. Taking the inventors' lab PoU sensors as test inputs, and the optimal regressor and tuning for each set of environmental condition offers even better performance, giving an optimised score of R² _(av)=0.70 (score averaged across each set of environmental conditions—FIG. 7.1 bottom left). The same process, but with external lab results as test inputs, produces on optimized score of R² _(av)=0.87 (FIG. 7.1 bottom right). This score for predicting levels of NO₃ ⁻ in soil is comparable to direct measurements using optical (R²=0.83; Fourier-transform infrared spectroscopy) or electrochemical methods (R²=0.96; ion selective electrodes) as reported in the literature.^([24,34]) This result was pleasantly surprising given that no additional hardware was required for determining levels of NO₃ with high accuracy. The inventors also tuned a Knn model (k=11, leaf size=3, p=1) to predict levels of NO₃ in soil using only the most basic inputs—days since fertilization, rainfall and temperature (i.e. requiring no soil sensors at all) which yielded R²=0.54 (FIG. S9 ).

With reference to FIG. S6 , machine learning models trained with readily available environmental data and PoU measurements enable prediction of difficult-to-measure soil nitrogen instantaneously with machine learning regressors (1). Prediction into the future is then enabled by treating data as time series in a LSTM neural network (2).

Data Processing for Machine Learning:

The following steps were taken to predict instantaneous soil—NO₃ ⁻ (FIG. S6.1 )

-   -   Anomalous data removed     -   Data for missing days interpolated smoothly with Akima spline     -   Time series length capped at 16 days     -   Data normalized over range 0-1     -   Feature selection: Features ranked for predicting NO₃ ⁻         calculated by weight and gain using XGBoost—see FIG. 7.1 .         Combinations are tested starting with all 7 features, then only         6 most important features, then the most important 5, down to         the single most important feature     -   Cross-validation: Data from each time series is removed from the         training data set sequentially, and used as test data instead     -   Regressor selection: Random Forest, Gradient Boosting, Adaboost,         Extra Trees, Knn and XGBoost were tested     -   Hyperparameter tuning: Grid search used to tune up to 3         hyperparameters for each regressor

The following steps were taken to predict soil-NH₄ ⁺ and soil-NO₃ ⁻ 1-12 days into the future (FIG. S6.2 )

-   -   Concatenate all time series into one multivariate time series     -   Normalize data −1<x<1 (for a bounded and stable neural network         computation)     -   Format time series data for supervised learning (generate         additional input features with time lag, generate output, which         is soil-NH₄ ⁺ and soil-NO₃ ⁻ at future time)     -   Remove each time series sequentially and train model on         remaining data     -   Predict the removed time series from its measurements on Day 0     -   Create LSTM model and tune hyperparameters with grid search         (time lag, epochs, batch size, number of neurons)     -   Record score (mean squared error) of predictions, repeat each         prediction 7 times and compare average scores to determine         optimal tuning, train LTSM model with optimal tuning to generate         predictions of NH₄ ⁺ and NO₃ ⁻ into the future

With reference to FIG. S7 , each time series 1-8 (corresponding to soil under different environmental conditions, by controlling rainfall and temperature—see FIG. 6 ) was sequentially removed from the data, and predicted using the remaining data. Testing all combinations of features, regressors and tuning parameters results in a best-case prediction score for each time series, shown in FIG. S7 . XGBoost is gives the best predictions for dryer soils and Knn for wetter soils. Poorer NO₃ ⁻ predictions at moderate (3-5 mm) rainfalls, where NO₃ ⁻ levels were relatively constant overtime. The number of features (n_features), regressor and optimal tuning parameters for each time series are listed below.

-   -   n_features=5, XGBoost (eta=0.0, gamma=0.0, max depth=6.0)     -   n_features=3, XGBoost (eta=0.0, gamma=0.0, max depth=6.0)     -   n_features=4, XGBoost (eta=0.0, gamma=0.0, max depth=7.0)     -   n_features=7, XGBoost (eta=0.0, gamma=0.0, max depth=1.0)     -   n_features=4, Knn (n neighbours=8.0, leaf size=1.0, p=1.0)     -   n_features=7, Knn score (k=50.0, leaf size=1.0, p=3.0)     -   n_features=7, Knn score (k=14.0, leaf size=1.0, p=1.0)     -   n_features=6, Knn score (k=20.0, leaf size=1.0, p=10.0)

With reference to FIG. S8 , the same process was followed as for FIG. 7.1 (bottom left), with the same tuning parameters (k=14, leaf size=1, p=1), but test inputs were from the external lab rather than PoU sensors from the inventors' lab, thus removing any impact of inaccuracy from the inventors' lab. The resulting score is R²=0.68 (compared to the R²=0.63 with inventors' lab inputs).

With reference to FIG. S9 , Knn predicts NO₃ ⁻ using a model tuned (k=11, leaf size=3, p=20) to only the most basic inputs—days since fertilization, rainfall and temperature (i.e. requiring no soil sensors at all.) with R²=0.54. One model was used for all environmental conditions.

Although determining the concentration of NH₄ ⁺ and NO₃ ⁻ in soil at any given moment is important (as described above), from an operational point of view, it would also be useful to know what the levels of soil nitrogen (i.e. NH₄ ⁺ and NO₃ ⁻) will be in the future from a single measurement to create a precise schedule for future fertilization. Soil, however, introduces a memory effect: nutrient levels today depend on the nutrient levels and other factors from yesterday (property X and time t will be a function of X at t−1). Forecasting of soil-N into the future must, therefore, consider time and sequence of data, and possess a degree of memory, for multiple correlated features. Using the time-series dataset generated by the external lab, a long short-term memory recurrent neural network (LSTM) model (another supervised ML algorithm) was trained to forecast NH₄ ⁺ and NO₃ ⁻ into the future for unseen environmental conditions. The model was tuned using grid search, minimizing root-mean-squared error using time lag and model hyperparameters (training epochs, batch size, number of neurons). The optimal tuning was time lag=1, epochs=50, batch size=3 and number of neurons=3. The dataset was first concatenated into one multivariate time series. Each time series was then removed sequentially, and the model trained to predict the removed time series from the remaining data. Models were retrained for each desired forecast time (1-12 days into the future). Predictions for longer time periods were distorted by subsequent time series in the concatenation. Comparing predicted to real values over the 12-day period gives a score of R² _(NH4+)=0.64 and R² _(NO3−)=0.70 using only the initial concentrations for NH₄ ⁺ and NO₃ ⁻ on Day 0 which demonstrates efficacy with even the limited training dataset (FIG. 7.2 , with R² plots in FIG. S10 ). In essence, by measuring NH₄ ⁺, EC and pH in the field and gathering other environmental data from public sources, levels of NO₃ can be estimated for today and both levels of NH₄ ⁺ and NO₃ ⁻ into the future.

With reference to FIG. 7 , low-cost PoU measurements and machine learning models were used to estimate crucial, difficult-to-measure, parameters in complex systems, then forecast them into the future. NO₃ ⁻ was predicted with instance based and ensemble learning regressors. Features were first ranked by importance to the XGBoost model, calculated by weight (number of times the feature occurs in the trees) and gain (each feature's contribution to each tree), shown in FIG. 7.1 (top left). Dryness is highly correlated with rainfall and temperature and can be predicted from temperature and rainfall using linear regression with R²=0.86 (FIG. S5 ), without requiring further analytical measurements. There are unique environmental conditions for each time series (by controlling rainfall and temperature). Each time series was sequentially removed from the complete dataset, before training a model with the remaining dataset to make predictions for the removed set of environmental conditions. The trained model then gave instantaneous predictions for NO₃ using only test inputs from PoU sensors in the inventors' lab (temperature, rainfall, calculated dryness, time since fertilization, EC, pH and NH₄ ⁺). Optimal feature combinations, regressors and tuning parameters were compared using grid search. Data processing steps are described in more detail in the SI. The best performing regressor for all environmental conditions is Knn, which predicts NO₃ using only PoU sensors from the inventors' lab as test inputs with R²=0.63 (FIG. 7.1 top right). Optimizing the model for each set of environmental conditions (regressor and tuning for each shown in FIG. S7 ) improves the score to R²=0.70 (FIG. 7.1 bottom left). Using external lab data as test inputs (removing any inaccuracy from the inventors' PoU sensors) gave optimized predictions for NO₃ ⁻ with R²=0.87 (FIG. 7.1 bottom right). The dataset was then used to train a LSTM-RNN model to forecast NH₄ ⁺ and NO₃ ⁻ into the future, also for unseen environmental conditions (FIG. 7.2 ). Each time series was removed sequentially, and the model trained on the remaining data. Feature time lag and model hyperparameters (training epochs, batch size, number of neurons) were tuned to optimize forecasting. Models were retrained for each desired forecast time (1-12 days into the future) and comparing predicted to real values over the 12 day period gives a score of R² _(NH4+)=0.64 and R² _(NO3−)=0.70.

With reference to FIG. S5 , in the dataset, dryness is highly correlated with rainfall and temperature. Dryness can be predicted using linear regression with R²=0.86 using the equation below, and hence can be estimated using these two metrics without needing further analytical measurements.

Dryness[%]=0.8853 Temperature[° C.]−3.0373 Rainfall[mm]+49.3928

FIG. S10 illustrates R² score for data in FIG. 7.2 , showing soil-NH₄ ⁺ and soil-NO₃ ⁻ predicted by LSTM ML model 1-12 days into the future. The LSTM ML model was poorer at predicting lower soil-NO₃ ⁻ levels and higher soil-NH₄ ⁺ levels.

In accordance with the above, it is possible to estimate the levels of hard-to-measure chemicals in soil using easily accessible soil/climate data and ML models. This entirely new strategy allows determining and predicting levels of nitrogen (NH₄ ⁺ and NO₃ ⁻) in soil, both instantaneously and into the future. The inventors have produced the first soil nitrification dataset that provides enough temporal resolution (˜3 day measurement frequency), for a range of conditions, to train a ML model. The strength of the present approach is that it primarily uses, inexpensive/easily accessible tools for the soil measurements (pH and EC meter with the exception of a new paper-based, gas-phase NH₄ ⁺ sensor developed in this work) and publicly available weather data (rainfall and temperature; in this study the inventors simulated weather in a controlled manner) to estimate the levels of soil nitrogen through ML. The method presented is remarkably high performance such that concentration of instantaneous soil-NO₃ ⁻ can be estimated using PoU inputs with R² _(av)=0.70, and using laboratory inputs with R² _(av)=0.87 (comparable to existing high performance NO₃ sensors) without the need for additional hardware. Using a LSTM model, the levels of NH₄ ⁺ and NO₃ ⁻ can also be forecast 12 days into the future, for unseen environmental conditions, with R² _(NH4+)=0.64 and R² _(NO3−)=0.70. Furthermore, the paper-based, disposable, gas-phase NH₄ ⁺ sensors (i.e. chemPEGS of the third embodiment above) developed in this work could also be used alone at the PoU without the ML model or other sensors if instantaneous detection of NH₄ ⁺ is needed alone. The approach presented in this work may have the following three potential weaknesses:

-   -   The supervised ML algorithms used for the prediction of soil-N         require a training dataset, meaning prior measurements/climate         data are needed to make the estimation algorithms work. This         problem could partially be resolved by using data for soil         nitrogen already published in the literature to create a         training dataset. A training dataset could also be created using         the PoU sensor toolkit described in this work in addition to         occasional measurements of soil-NO₃ ⁻ in an external laboratory.         It is expected that performance of the algorithms will increase         over time as more data are generated using the sensors and         laboratory measurements. The LSTM approach also concatenated all         training data into one long multivariate time series, resulting         in a model that would only predict cyclical patterns if allowed         to predict longer times than the length of the input time series         (t≥16 days). This problem may be addressed by treating each set         of environmental conditions as panel data (with separate         multivariate time series for PoU measurements in different         locations/environmental conditions), linking between panels and         training over longer time periods.     -   chemPEGS (for measuring NH₄ ⁺ at the PoU) may be cross-sensitive         to other alkaline gases and currently takes a long time to         perform a measurement; 30-450 minutes for 144-4.5 ppm NH₄ ⁺.         chemPEGS, however, demonstrated sufficient performance for         measuring soil-NH₄ ⁺ as it is most sensitive to NH_(3(g)) due to         its high water solubility. The time it takes to produce a result         could also be reduced by measuring the rate of change during         neutralization or training a predictive machine learning model         on short measurement times. The sensitivity of chemPEGS could         also be improved by using a lower concentration of         H₂SO₄.^([35,36])     -   The dataset generated is limited (sparse) and does not include         various scenarios such as sudden changes in weather, different         types of soils and fertilizers (e.g., urea). The current work         also does not include crops, which would draw nitrogen from the         soil and affect nitrogen dynamics. Further work is needed to         create a model to predict nitrogen uptake by plants.

The impact of this work is that growers can instantly determine crucial soil nutrients using only point-of-use measurements and weather data, and forecast nutrients into the future to build better fertilization plans. This would ensure that appropriate nutrients are present, when needed, by the crops. This approach could enable precision farming of a new calibre (with significantly lowered capital investment), reducing fertilizer requirements, soil degradation and eutrophication, while improving crop yields. Furthermore, it is hoped this approach will extend to complex media other than soil, where simple chemical measurements and easily accessible data, combined with machine learning, can be used to predict, and forecast crucial outputs in healthcare, food and environmental monitoring.

Soil experiments: Top soil with sandy loam texture (69% sand 2.00-0.063 mm diameter, 25% silt 0.063-0.002 mm diameter, 6% clay <0.002 mm diameter, density 774 g/l measured in NRM Laboratories, part of Cawood Scientific, United Kingdom) was purchased from Westland and used in the experiments without further modifications. For the soil experiments performed in the inventors' laboratory, the water-soluble compounds and small particles were extracted from the soil samples by mixing 100 ml diH₂O with 100 g of soil, and pressing with a potato press (VonShef). The solution extracted was used in the subsequent, pH, EC and NH₄ ⁺ measurements in the inventors' laboratory. Soil samples (200 g), for the measurements at the external laboratory (NRM), were extracted from the soil pots and stored in a Ziploc bag (placed inside a cool box along with cooling element) which were collected and analysed within 2 days. Different to the inventors' method of handling, the external lab used a soil-to-water ratio of 1:2.5 as they dried the samples before processing to improve consistency (this was not done, which caused issues surrounding unmatching results between the external measurements and measurements performed by the inventors' group). Levels of soil nitrogen were measured colorimetrically by the external laboratory. NH₄ ⁺ was reacted with alkaline hypochlorite and phenol to form indophenol blue. Sodium nitroprusside acted as a catalyst in formation of indophenol blue which was measured at 640 nm. NO₃ ⁻ was reduced to nitrate using cadmium in an open tubular cadmium reactor. A diazo compound formed between nitrite and sulphanilamide, which was coupled with N-(1-Napthyl)ethylenediamine dihydrochloride to give a red azo dye, measured at 540 nm. For all soil experiments, soil was weighed into pots of 5.1 kg, and fertilized with 51 ml 0.665 M (12,000 ppm) NH₄NO₃ while mixing thoroughly, resulting in soil at approximately 120 ppm NH₄NO₃.

Control of rainfall and temperature: Rainfall was fixed at 1, 3, 5, or 10 mm/day, implemented by adding a daily equivalent (pots were watered every 2 days) of 57 ml, 172 ml, 286 ml and 573 ml respectively to a pot area of 573 cm². Temperature was controlled by wrapping pots containing soil with nichrome wire (purchased from Amazon) and applying a 36 V potential, resulting in an electrical current of 1.5 A supplied from two Tenma 72-8350A power supplies in series. Soil temperature was measured at 3 points (centre, edge and in between) and averaged to estimate the temperature of soil periodically, using a Silverline 469539 Pocket Digital Probe Thermometer.

Measurement of EC and pH of soil: Using a Hanna Instruments H15222-type benchtop EC/pH meter, the pH and EC of the solution extracted from the samples of soil were measured. Each sample was measured five times and the readings were averaged to reduce error.

Machine learning model: All computational work was performed using Python (3.6) in PyCharm integrated development environment. For modelling and optimization, the following core packages were used: Keras API for Tensorflow (LSTM model), Scikit-learn (ensemble and Knn regressors), XGBoost, pandas and NumPy.

The following references, cited above, are incorporated by reference.

-   [1] United Nations, World Population Prospects 2019, 2019. -   [2] R. Mosheim, United States Dep. Agric.—Econ. Res. Serv. 2019. -   [3] N. Alexandratos, J. Bruinsma, Land use policy 2012, DOI     10.1016/S0264-8377(03)00047-4. -   [4] R. N. Tetteh, 2015, 6, 301. -   [5] K. T. Osman, Soil Degradation, Conservation and Remediation,     2014. -   [6] V. H. Smith, G. D. Tilman, J. C. Nekola, in Environ. Pollut.,     1999. -   [7] F. Zheng, D. Zhu, M. Giles, T. Daniell, R. Neilson, Y. G.     Zhu, X. R. Yang, Sci. Total Environ. 2019, DOI     10.1016/j.scitotenv.2019.04.384. -   [8] Q. Wang, M. Ma, X. Jiang, D. Guan, D. Wei, B. Zhao, S. Chen, F.     Cao, L. Li, X. Yang, J. Li, Appl. Soil Ecol. 2019, DOI     10.1016/j.apsoil.2018.12.019. -   [9] J. F. Rosas, Card Work. Pap. 2012. -   [10] J. Melkonian, H. Van Es, A. Degaetano, J. Sogbedji, L. Joseph,     Proc. Symp. Integrating Weather Var. into Nitrogen Recomm. 2007. -   [11] Q. Zhu, J. P. Schmidt, H. S. Lin, R. P. Sripada, Geoderma 2009,     DOI 10.1016/j.geoderma.2009.10.004. -   [12] J. F. Shanahan, N. R. Kitchen, W. R. Raun, J. S. Schepers,     Comput. Electron. Agric. 2008, DOI 10.1016/j.compag.2007.06.006. -   [13] N. Tremblay, Y. M. Bouroubi, C. Belec, R. W. Mullen, N. R.     Kitchen, W. E. Thomason, S. Ebelhar, D. B. Mengel, W. R. Raun, D. D.     Francis, E. D. Vories, I. Ortiz-Monasterio, Agron. J. 2012, 104,     1658. -   [14] C. Cilia, C. Panigada, M. Rossini, M. Meroni, L. Busetto, S.     Amaducci, M. Boschetti, V. Picchi, R. Colombo, Remote Sens. 2014,     DOI 10.3390/rs6076549. -   [15] N. R. Kitchen, K. A. Sudduth, S. T. Drummond, P. C.     Scharf, H. L. Palm, D. F. Roberts, E. D. Vories, Agron. J. 2010, DOI     10.2134/agronj2009.0114. -   [16] M. L. Stone, J. B. Solie, W. R. Raun, R. W. Whitney, S. L.     Taylor, J. D. Ringer, Trans. Am. Soc. Agric. Eng. 1996, DOI     10.13031/2013.27678. -   [17] S. M. Sze, K. K. Ng, J.-P. Colinge, C. A. Colinge, Phys.     Semicond. Devices 2006, i. -   [18] H. J. Kim, J. W. Hummel, S. J. Birrell, Trans. ASABE 2006. -   [19] R. Shaw, R. M. Lark, A. P. Williams, D. R. Chadwick, D. L.     Jones, Agric. Ecosyst. Environ. 2016, DOI     10.1016/j.agee.2016.06.004. -   [20] T. Hengl, J. G. B. Leenaars, K. D. Shepherd, M. G.     Walsh, G. B. M. Heuvelink, T. Mamo, H. Tilahun, E. Berkhout, M.     Cooper, E. Fegraus, I. Wheeler, N. A. Kwabena, Nutr. Cycl.     Agroecosystems 2017, 109, 77. -   [21] B. Zaman, M. McKee, Open J. Mod. Hydrol. 2014, 04, 80. -   [22] C. Brewster, I. Roussaki, N. Kalatzis, K. Doolin, K. Ellis,     IEEE Commun. Mag. 2017, DOI 10.1109/MCOM.2017.1600528. -   [23] K. L. Tully, R. Weil, Commun. Soil Sci. Plant Anal. 2014, 45,     1974. -   [24] J. Choosang, A. Numnuam, P. Thavarungkul, P. Kanatharana, T.     Radu, S. Ullah, A. Radu, Sensors (Switzerland) 2018, 18, DOI     10.3390/s18103555. -   [25] R. Burton, “Nitrate Sensing in the Soil,” can be found under     https://www.cambridgeconsultants.com/insights/nitrate-sensing-in-the-soil,     2016. -   [26] R. Shaw, A. P. Williams, A. Miller, D. L. Jones, Agric. 2013,     DOI 10.3390/agriculture3030327. -   [27] G. Barandun, M. Soprani, S. Naficy, M. Grell, M.     Kasimatis, K. L. Chiu, A. Ponzoni, F. Güder, ACS Sensors 2019, DOI     10.1021/acssensors.9b00555. -   [28] F. Beeckman, H. Motte, T. Beeckman, Curr. Opin. Biotechnol.     2018, DOI 10.1016/j.copbio.2018.01.014. -   [29] J. M. Stark, M. K. Firestone, Appl. Environ. Microbiol. 1995,     61, 218. -   [30] L. T. T. Nguyen, Y. Osanai, I. C. Anderson, M. P. Bange, M.     Braunack, D. T. Tissue, B. K. Singh, Plant Soil 2018, 426, 299. -   [31] A. E. Taylor, A. T. Giguere, C. M. Zoebelein, D. D.     Myrold, P. J. Bottomley, ISME J. 2017, 11, 896. -   [32] T. Hao, Q. Zhu, M. Zeng, J. Shen, X. Shi, X. Liu, F. Zhang, W.     de Vries, J. Environ. Manage. 2020, 270, 110888. -   [33] J. L. Smith, J. W. Doran, Soil Sci. Soc. Am. 1996, 169. -   [34] N. Rogovska, D. A. Laird, C. P. Chiou, L. J. Bond, Precis.     Agric. 2019, 20, 40. -   [35] N. Albilal, Nanomaterials for Pregnancy Detection, Imperial     College London, 2014. -   [36] M. Grell, C. Dincer, T. Le, A. Lauri, E. Nunez Bajo, M.     Kasimatis, G. Barandun, S. A. Maier, A. E. G. Cass, F. Güder, Adv.     Funct. Mater. 2018, DOI 10.1002/adfm.201804798.

It will be appreciated that the above description is made by way of example and not limitation of the scope of the appended claims, including any equivalents as included within the scope of the claims. Various modifications are possible and will be readily apparent to the skilled person in the art. Likewise, features of the described embodiments can be combined with any appropriate aspect described above and optional features of any one aspect can be combined with any other appropriate aspect. 

1. A gas sensor for sensing a target gas, the gas sensor comprising: first and second electrodes; a support layer between the first and second electrodes; and a reagent on the support layer for binding the target gas; wherein the first and second electrodes are in electrical contact with the support layer and the reagent.
 2. The gas sensor of claim 1, further comprising a voltage source, wherein the voltage source is configured to apply an electrical potential between the first and second electrodes.
 3. The gas sensor of claim 1, wherein the target gas is an alkaline gas and the reagent is acidic.
 4. The gas sensor of claim 3, wherein the target gas is ammonia or an alkyl amine.
 5. The gas sensor of claim 1, wherein the target gas is an acidic gas and the reagent is alkaline.
 6. The gas sensor of claim 5, wherein the target gas is carbon dioxide, hydrogen fluoride, hydrogen chloride, hydrogen bromide or hydrogen iodide.
 7. The gas sensor of claim 1, wherein the gas sensor is a device for determining a quantity of target ions in a sample, the gas sensor further comprising a container for receiving the sample, wherein the container is fluidically connected to the gas sensor.
 8. The gas sensor of claim 7, wherein the target ions in the sample are ammonium ions, alkylammonium ions, fluoride ions, chloride ions, bromide ions, iodide ions or bicarbonate ions.
 9. The gas sensor of claim 7, wherein the sample is soil, agricultural runoff, river water, sea water, sewage, blood, urine, an extract of soil, an extract of agricultural runoff, an extract of river water, an extract of sea water, an extract of sewage, an extract of blood, or an extract of urine.
 10. The gas sensor of claim 7, wherein the container contains or is fluidically connected to a reagent for converting the target ions in the sample into the target gas.
 11. The gas sensor of claim 10, wherein the reagent for converting the target ions in the sample into the target gas is an acidic or basic solution.
 12. The gas sensor of claim 7, wherein the sample is soil extract, the ions are ammonium ions and the container contains a sodium hydroxide solution.
 13. A method of determining a concentration of a target gas, the method comprising: exposing a gas sensor to a gas sample comprising a target gas, such that the target gas is bound by a reagent, wherein the gas sensor comprises first and second electrodes, a support layer between the first and second electrodes, and a reagent on the support layer for binding the target gas, the first and second electrodes being in electrical contact with the support layer and the reagent; measuring an impedance of the support layer by applying, at a first time, an electrical potential between the first and second electrodes; measuring an impedance of the support layer by applying, at a second time, an electrical potential between the first and second electrodes; and determining the concentration of the target gas based on the impedance at the first time and the impedance at the second time.
 14. A method of determining a concentration of target ions in a sample using a gas sensor device, the gas sensor device comprising a gas sensor, wherein the gas sensor comprises first and second electrodes, a support layer between the first and second electrodes, and a reagent on the support layer for binding target gas, the first and second electrodes being in electrical contact with the support layer and the reagent, the gas sensor device further comprising a container for receiving the sample, the container being fluidically connected to the gas sensor, the gas sensor device being a device for determining a quantity of the target ions in the sample, the method comprising: inserting the sample into the container; mixing the sample with the reagent for converting the target ions in the sample into the target gas, thereby releasing the target gas into the container; measuring an impedance of the support layer by applying an electrical potential between the first and second electrodes at a first time; measuring an impedance of the support layer by applying an electrical potential between the first and second electrodes at a second time; and determining the concentration of target ions in the sample based on the impedance at the first time and the impedance at the second time.
 15. The method of according to claim 14, wherein the reagent is an acidic or basic solution.
 16. The method of claim 14, wherein the determined concentration of target ions comprises a determined concentration of ammonium ions in a soil sample, wherein the gas sensor device is a device for determining a quantity of the target ions in the sample, the gas sensor device further comprising a container for receiving the sample, the container being fluidically connected to the gas sensor, the container containing or being fluidically connected to the reagent for converting the target ions in the sample into the target gas.
 17. The method of claim 16, wherein the reagent is an acidic or basic solution.
 18. The gas sensor of claim 8, wherein the sample is soil, agricultural runoff, river water, sea water, sewage, blood, urine, an extract of soil, an extract of agricultural runoff, an extract of river water, an extract of sea water, an extract of sewage, an extract of blood, or an extract of urine.
 19. The gas sensor of claim 8, wherein the container contains or is fluidically connected to a reagent for converting the target ions in the sample into the target gas.
 20. The gas sensor of claim 9, wherein the container contains or is fluidically connected to a reagent for converting the target ions in the sample into the target gas. 